package com.hy.controller;

import com.hy.bean.*;
import com.hy.service.ClienttableService;
import com.hy.service.impl.ClienttableServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Clienttable)表控制层
 *
 * @author makejava
 * @since 2024-05-14 22:03:32
 */
@CrossOrigin
@RestController
@RequestMapping("clienttable")
public class ClienttableController {
    /**
     * 服务对象
     */
    @Resource
    private ClienttableService clienttableService;

    /**
     * 分页查询
     *
     * @return 查询结果
     */
    @GetMapping("/list")
    public RespBean queryAll(Integer page,Integer limit) {

        return clienttableService.queryAll(page,limit);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/getById/{id}")
    public RespBean queryById(@PathVariable("id") Integer id) {
        return clienttableService.getById(id);
    }

    /**
     * 通过实体作为筛选条件查询
     * @param clientName
     * @return
     */
    @RequestMapping("/queryByClientName")
    public RespBean queryByClientName(String clientName) {

        return clienttableService.queryByClientName(clientName);
    }
    /**
     * 新增数据
     *
     * @param clienttable 实体
     * @return 新增结果
     */
    @PostMapping("/add")
    public RespBean add(@RequestBody Clienttable clienttable) {
        return clienttableService.addClienttable(clienttable);
    }

    /**
     * 编辑数据
     *
     * @param clienttable 实体
     * @return 编辑结果
     */
    @PutMapping("/update")
    public RespBean edit(@RequestBody Clienttable clienttable) {
        System.out.println(clienttable);
        return clienttableService.updateClienttable(clienttable);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping("/deleteByid/{id}")
    public RespBean deleteById(@PathVariable("id") Integer id) {
        return clienttableService.deleteById(id);
    }


    @GetMapping("queryPrintClientLimit")
    public RespBean queryPrintClientLimit(Integer pageSize, Integer currentPage, String clientname, String linkman, String type){

        return clienttableService.getPrintClientLimit(pageSize,currentPage,clientname,linkman,type);
    }

}

